package com.gemme.gemme.view;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.gemme.gemme.R;

public class VipSgView extends RelativeLayout {
    private Context context;
    public VipSgView(Context context) {
        this(context,null);
    }

    public VipSgView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public VipSgView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
        initView();
    }
    RoundCheckBox cbox;
    boolean isCheck = false;
    View content;
    View ll_bottom;
    TextView tv_price;
    TextView tv_name;
    private void initView() {
        LayoutInflater.from(context).inflate(R.layout.vip_sg_view,this);

        content = findViewById(R.id.content);
        tv_price = findViewById(R.id.tv_price);
        ll_bottom = findViewById(R.id.ll_bottom);


        tv_name = findViewById(R.id.tv_name);

        cbox = findViewById(R.id.cbox);
        cbox.setChecked(isCheck);

        changeSatate();

      /*  cbox.setOnChangeLIstener(new OnChangeLIstener() {
            @Override
            public void onChangeLIstener() {
                isCheck = cbox.isChecked();
                changeSatate();
            }
        });*/
    }

    public RoundCheckBox getCbox(){
        return cbox;
    }

    public void setIsCheck(boolean isCheck){
        this.isCheck = isCheck;
        changeSatate();
    }

    private void changeSatate() {
        if(isCheck){
            content.setBackgroundResource(R.drawable.shape_pick_corn10);
            ll_bottom.setBackgroundResource(R.drawable.shape_pick_bottom_corn10);
        }else{
            content.setBackgroundResource(R.drawable.shape_white_corn10);
            ll_bottom.setBackgroundResource(R.drawable.shape_vipno_bottom_corn10);
        }

        cbox.setChecked(isCheck);
    }

    public void setSatate(boolean isCheck){
        this.isCheck = isCheck;
        changeSatate();
    }

    public void setPrice(String price){
        tv_price.setText(price + "");
    }

    public void setName(String str){
        tv_name.setText(str + "");
    }

}
